package com.huang.wangpan.strategy.process;

import com.huang.wangpan.service.GetDataService;
import com.huang.wangpan.utils.ResultData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author: liminghui
 * @Date: 2020/11/7 12:37
 * @Version:
 * @Description:
 */
@Component
public class GetNewFloderProcess implements CommonProcess {
    @Autowired
    GetDataService getDataService;

    private static final Logger logger = LoggerFactory.getLogger(GetNewFloderProcess.class);

    @Override
    public void process(String method, HttpServletRequest request, HttpServletResponse response) {
        logger.info("GetNewFloderProcess-->process创建新的文件夹或者文件");
        String name = request.getParameter("name");
        String newpath = request.getParameter("currentpath");
        String Catalogue = request.getParameter("Catalogue");
        String isfloder = request.getParameter("file");
        int page = Integer.parseInt(Catalogue);
        ResultData rd = getDataService.CreateNewFile(request, newpath, name, page, isfloder);
        rd.writeToResponse(response);
    }
}
